﻿<UserControl x:Class="Microsoft.Research.ScientificWorkflow.UIDesigner.PropertyListControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
             xmlns:Converters1="clr-namespace:Microsoft.Research.ScientificWorkflow.UIDesigner"
             xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero">
    <UserControl.Resources>
        <Converters1:PropertyValueTemplateSelectorForList x:Key="PropertyValueTemplateSelector"/>
        <Converters1:InputControlConverter x:Key="ValueControlSelector"/>
        <Converters1:PropertyListNameTooltipGenerator x:Key="PropertyNameTooltipGenerator"/>
        <BooleanToVisibilityConverter x:Key="ErrorDockVisibilityConverter"></BooleanToVisibilityConverter>
        <Converters1:ErrorTooltipGenerator x:Key="ErrorTooltipGenerator"></Converters1:ErrorTooltipGenerator>
        <Converters1:OppositeVisibilityConverter x:Key="oppositeVisibilityConverter"></Converters1:OppositeVisibilityConverter>
        <!--For the property name-->
        <DataTemplate x:Key="NameTemplate">
            <Grid Margin="0,3,3,0" DockPanel.Dock="Left" HorizontalAlignment="Left">
                <TextBlock Text="{Binding Path=PropertyPaneDisplayName}" ToolTip="{Binding Converter={StaticResource PropertyNameTooltipGenerator}, Path=.}" TextWrapping="NoWrap" TextTrimming="CharacterEllipsis" HorizontalAlignment="Left"/>
            </Grid>
        </DataTemplate>
        
        <!--For the editable properties-->
        <DataTemplate x:Key="EditableValueTemplate">
            <Grid Name="txtBxEditable" ToolTip="{Binding Path=Value, Mode=TwoWay}" HorizontalAlignment="Stretch">
                <TextBox Loaded="OnInputValueTextBoxLoaded" LostFocus="OnInputValueTextBoxLostFocus" 
                             TextChanged="OnInputValTextChanged" HorizontalAlignment="Stretch"   
                             Text="{Binding Path=Value, Mode=TwoWay, UpdateSourceTrigger=Explicit}" Foreground="Black" 
                             AutomationProperties.AutomationId="{Binding Path=PropertyPaneDisplayName, StringFormat={}{0}_text}"/>
                <DockPanel HorizontalAlignment="Left" Margin="-7,-6.4,0,0" Name="errorDckCustomType" Visibility="{Binding Path=IsValueInvalid, Converter={StaticResource ErrorDockVisibilityConverter}}" ToolTip="{Binding Converter={StaticResource ErrorTooltipGenerator}}">
                    <Grid DockPanel.Dock="Left" Margin="2,0" Width="12" Height="12">
                        <Ellipse Fill="#FFC42A2A" Stroke="{x:Null}"/>
                        <Path Fill="#FFFFFFFF" Stretch="Fill" Stroke="{x:Null}" StrokeThickness="2" Margin="4.94,2.235,4.644,5.12" Data="M11.701627,8.0009042 L12.372672,15.173164 14.011686,15.241177 14.56827,7.8270056 z"/>
                        <Path Fill="#FFFFFFFF" Stretch="Fill" Stroke="{x:Null}" StrokeThickness="2" Margin="5.121,0,4.779,1.746" VerticalAlignment="Bottom" Height="2.1" Data="M11.395564,17.238573 L14.853121,17.333691 14.771832,21.163108 11.102494,20.999791 z"/>
                    </Grid>
                </DockPanel>
            </Grid>
        </DataTemplate>
        
        <!--For the bound properties-->
        <DataTemplate x:Key="NonEditableValueTemplate">
            <DockPanel Name="txtBxNonEditable" LastChildFill="False" ToolTip="This input is data bound to another activity's output. Bound values cannot be changed here.">
                <TextBox Opacity="0.7" IsReadOnly="True" DockPanel.Dock="Left" HorizontalAlignment="Stretch" AutomationProperties.AutomationId="{Binding Path=PropertyPaneDisplayName, StringFormat={}{0}_Bind}">
                    <TextBox.Text>
                        <MultiBinding Converter="{StaticResource ValueControlSelector}" ConverterParameter="ReadOnlyBoundTextBox">
                            <Binding Mode="OneWay"/>
                            <Binding Mode="OneWay" Path="Value"/>
                        </MultiBinding>
                    </TextBox.Text>
                    <TextBox.ToolTip>
                        <MultiBinding Converter="{StaticResource ValueControlSelector}" ConverterParameter="ReadOnlyBoundTextBoxTooltip">
                            <Binding Mode="OneWay"/>
                            <Binding Mode="OneWay" Path="Value"/>
                        </MultiBinding>
                    </TextBox.ToolTip>
                </TextBox>
            </DockPanel>
        </DataTemplate>
        
        <!--The drop down representing enums-->
        <DataTemplate x:Key="ComboboxTemplate" DataType="ParameterDescriptionModel">
            <DockPanel LastChildFill="False">
                <DockPanel>
                    <ComboBox DisplayMemberPath="Value" Loaded="ComboBox_Loaded" SelectedValuePath="Key" SelectionChanged="OnDropDownSelectionChanged" AutomationProperties.AutomationId="{Binding Path=PropertyPaneDisplayName, StringFormat={}{0}_combo}">
                        <ComboBox.ItemsSource>
                            <MultiBinding Converter="{StaticResource ValueControlSelector}" ConverterParameter="comboBoxCtrl">
                                <Binding Mode="OneWay"/>
                            </MultiBinding>
                        </ComboBox.ItemsSource>
                    </ComboBox>
                </DockPanel>
            </DockPanel>
        </DataTemplate>
        
        <DataTemplate x:Key="CustomDatatypeTemplate">
            <DockPanel LastChildFill="True">
                <Button Name="btnCustomType" Content="..." DockPanel.Dock="Right" MinWidth="25" Margin="4,0,0,0" Click="OnCustomTypeInitClick" ToolTip="Launch type initializer"/>
                <Grid DockPanel.Dock="Left">
                    <TextBox Name="txtBxParamValue" Opacity="0.7" IsReadOnly="True" HorizontalAlignment="Stretch" Loaded="OnCustomTypeValLoaded"
                                 TextChanged="OnCustomValueTextChanged">
                        <TextBox.Text>
                            <MultiBinding BindingGroupName="textGrpCustomBox" Converter="{StaticResource ValueControlSelector}" ConverterParameter="CustomTypeTextBox">
                                <Binding Mode="OneWay"/>
                                <Binding Mode="OneWay" Path="Value"/>
                            </MultiBinding>
                        </TextBox.Text>
                        <TextBox.ToolTip>
                            <MultiBinding BindingGroupName="tooltipGrpCustomBox" Converter="{StaticResource ValueControlSelector}" ConverterParameter="CustomTypeTextBox">
                                <Binding Mode="OneWay"/>
                                <Binding Mode="OneWay" Path="Value"/>
                            </MultiBinding>
                        </TextBox.ToolTip>
                    </TextBox>
                    <!--Do not change name of the dockpanel, being used via FindName-->
                    <DockPanel HorizontalAlignment="Left" Margin="-7,-6.4,0,0" Name="errorDckCustomType" Visibility="{Binding Path=IsValueInvalid, Converter={StaticResource ErrorDockVisibilityConverter}}" ToolTip="{Binding Converter={StaticResource ErrorTooltipGenerator}}">
                        <Grid DockPanel.Dock="Left" Margin="2,0" Width="12" Height="12">
                            <Ellipse Fill="#FFC42A2A" Stroke="{x:Null}"/>
                            <Path Fill="#FFFFFFFF" Stretch="Fill" Stroke="{x:Null}" StrokeThickness="2" Margin="4.94,2.235,4.644,5.12" Data="M11.701627,8.0009042 L12.372672,15.173164 14.011686,15.241177 14.56827,7.8270056 z"/>
                            <Path Fill="#FFFFFFFF" Stretch="Fill" Stroke="{x:Null}" StrokeThickness="2" Margin="5.121,0,4.779,1.746" VerticalAlignment="Bottom" Height="2.1" Data="M11.395564,17.238573 L14.853121,17.333691 14.771832,21.163108 11.102494,20.999791 z"/>
                        </Grid>
                    </DockPanel>
                </Grid>
            </DockPanel>
        </DataTemplate>
        
        <!-- Styles-->
        <SolidColorBrush x:Key="ListBorder" Color="#828790"/>
        <Style x:Key="{x:Static GridView.GridViewScrollViewerStyleKey}" TargetType="{x:Type ScrollViewer}">
            <Setter Property="Focusable" Value="false"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ScrollViewer}">
                        <Grid SnapsToDevicePixels="true" Background="{TemplateBinding Background}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <DockPanel Margin="{TemplateBinding Padding}">
                                <ScrollViewer Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" DockPanel.Dock="Top">
                                    <GridViewHeaderRowPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="2,0,2,0" AllowsColumnReorder="{Binding Path=TemplatedParent.View.AllowsColumnReorder, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderContainerStyle="{Binding Path=TemplatedParent.View.ColumnHeaderContainerStyle, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderContextMenu="{Binding Path=TemplatedParent.View.ColumnHeaderContextMenu, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderTemplate="{Binding Path=TemplatedParent.View.ColumnHeaderTemplate, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderTemplateSelector="{Binding Path=TemplatedParent.View.ColumnHeaderTemplateSelector, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderToolTip="{Binding Path=TemplatedParent.View.ColumnHeaderToolTip, RelativeSource={RelativeSource TemplatedParent}}" Columns="{Binding Path=TemplatedParent.View.Columns, RelativeSource={RelativeSource TemplatedParent}}"/>
                                </ScrollViewer>
                                <ScrollContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="PART_ScrollContentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" CanContentScroll="{TemplateBinding CanContentScroll}" KeyboardNavigation.DirectionalNavigation="Local"/>
                            </DockPanel>
                            <ScrollBar Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Cursor="Arrow" x:Name="PART_HorizontalScrollBar" Grid.Row="1" Orientation="Horizontal" ViewportSize="{TemplateBinding ViewportWidth}" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0.0" Value="{Binding Path=HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                            <ScrollBar Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Cursor="Arrow" x:Name="PART_VerticalScrollBar" Grid.Column="1" Orientation="Vertical" ViewportSize="{TemplateBinding ViewportHeight}" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0.0" Value="{Binding Path=VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                            <DockPanel Grid.Column="1" Grid.Row="1" Background="{Binding Path=Background, ElementName=PART_VerticalScrollBar}" LastChildFill="false">
                                <Rectangle Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Width="1" Fill="White" DockPanel.Dock="Left"/>
                                <Rectangle Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Height="1" Fill="White" DockPanel.Dock="Top"/>
                            </DockPanel>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="ListViewStyle1" TargetType="{x:Type ListView}">
            <Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
            <Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
            <Setter Property="BorderThickness" Value="1"/>
            <Setter Property="Foreground" Value="#FF042271"/>
            <Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
            <Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
            <Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ListView}">
                        <Microsoft_Windows_Themes:ListBoxChrome SnapsToDevicePixels="true" x:Name="Bd" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" RenderFocused="{TemplateBinding IsKeyboardFocusWithin}" RenderMouseOver="{TemplateBinding IsMouseOver}">
                            <ScrollViewer Padding="{TemplateBinding Padding}" Style="{DynamicResource ScrollViewerStyle1}">
                                    <Grid>
                                        <ItemsPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
                                        <TextBlock HorizontalAlignment="Center" Visibility="{Binding Path=HasItems, RelativeSource={RelativeSource Mode=TemplatedParent}, Converter={StaticResource oppositeVisibilityConverter}}">No Items to be shown.</TextBlock>
                                    </Grid>
                                </ScrollViewer>
                        </Microsoft_Windows_Themes:ListBoxChrome>
                        <ControlTemplate.Triggers>
                            <Trigger Property="IsGrouping" Value="true">
                                <Setter Property="ScrollViewer.CanContentScroll" Value="false"/>
                            </Trigger>
                            <Trigger Property="IsEnabled" Value="false">
                                <Setter Property="Background" TargetName="Bd" Value="{DynamicResource {x:Static SystemColors.ControlBrushKey}}"/>
                            </Trigger>
                        </ControlTemplate.Triggers>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <Style x:Key="ScrollViewerStyle1" TargetType="{x:Type ScrollViewer}">
            <Setter Property="Focusable" Value="false"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type ScrollViewer}">
                        <Grid SnapsToDevicePixels="true" Background="{TemplateBinding Background}">
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition Width="*"/>
                                <ColumnDefinition Width="Auto"/>
                            </Grid.ColumnDefinitions>
                            <Grid.RowDefinitions>
                                <RowDefinition Height="*"/>
                                <RowDefinition Height="Auto"/>
                            </Grid.RowDefinitions>
                            <DockPanel Margin="{TemplateBinding Padding}">
                                <ScrollViewer Focusable="false" HorizontalScrollBarVisibility="Hidden" VerticalScrollBarVisibility="Hidden" DockPanel.Dock="Top">
                                    <GridViewHeaderRowPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" Margin="0,0,0,0" AllowsColumnReorder="{Binding Path=TemplatedParent.View.AllowsColumnReorder, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderContainerStyle="{DynamicResource GridViewColumnHeaderStyle1}" ColumnHeaderContextMenu="{Binding Path=TemplatedParent.View.ColumnHeaderContextMenu, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderTemplate="{Binding Path=TemplatedParent.View.ColumnHeaderTemplate, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderTemplateSelector="{Binding Path=TemplatedParent.View.ColumnHeaderTemplateSelector, RelativeSource={RelativeSource TemplatedParent}}" ColumnHeaderToolTip="{Binding Path=TemplatedParent.View.ColumnHeaderToolTip, RelativeSource={RelativeSource TemplatedParent}}" Columns="{Binding Path=TemplatedParent.View.Columns, RelativeSource={RelativeSource TemplatedParent}}"/>
                                </ScrollViewer>
                                <ScrollContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" x:Name="PART_ScrollContentPresenter" Content="{TemplateBinding Content}" ContentTemplate="{TemplateBinding ContentTemplate}" CanContentScroll="{TemplateBinding CanContentScroll}" KeyboardNavigation.DirectionalNavigation="Local"/>
                            </DockPanel>
                            <ScrollBar Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Cursor="Arrow" x:Name="PART_HorizontalScrollBar" Grid.Row="1" Orientation="Horizontal" ViewportSize="{TemplateBinding ViewportWidth}" Maximum="{TemplateBinding ScrollableWidth}" Minimum="0.0" Value="{Binding Path=HorizontalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                            <ScrollBar Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Cursor="Arrow" x:Name="PART_VerticalScrollBar" Grid.Column="1" Orientation="Vertical" ViewportSize="{TemplateBinding ViewportHeight}" Maximum="{TemplateBinding ScrollableHeight}" Minimum="0.0" Value="{Binding Path=VerticalOffset, Mode=OneWay, RelativeSource={RelativeSource TemplatedParent}}"/>
                            <DockPanel Grid.Column="1" Grid.Row="1" Background="{Binding Path=Background, ElementName=PART_VerticalScrollBar}" LastChildFill="false">
                                <Rectangle Visibility="{TemplateBinding ComputedVerticalScrollBarVisibility}" Width="1" Fill="White" DockPanel.Dock="Left"/>
                                <Rectangle Visibility="{TemplateBinding ComputedHorizontalScrollBarVisibility}" Height="1" Fill="White" DockPanel.Dock="Top"/>
                            </DockPanel>
                        </Grid>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <LinearGradientBrush x:Key="GridViewColumnHeaderBackground" EndPoint="0,1" StartPoint="0,0">
            <GradientStop Color="#FFFFFFFF" Offset="0"/>
            <GradientStop Color="#FFFFFFFF" Offset="0.4091"/>
            <GradientStop Color="#FFF7F8F9" Offset="1"/>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="GridViewColumnHeaderBorderBackground" EndPoint="0,1" StartPoint="0,0">
            <GradientStop Color="#FFF2F2F2" Offset="0"/>
            <GradientStop Color="#FFD5D5D5" Offset="1"/>
        </LinearGradientBrush>
        <Style x:Key="GridViewColumnHeaderGripper" TargetType="{x:Type Thumb}">
            <Setter Property="Canvas.Right" Value="-9"/>
            <Setter Property="Width" Value="18"/>
            <Setter Property="Height" Value="{Binding Path=ActualHeight, RelativeSource={RelativeSource TemplatedParent}}"/>
            <Setter Property="Padding" Value="0"/>
            <Setter Property="Background" Value="{StaticResource GridViewColumnHeaderBorderBackground}"/>
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="{x:Type Thumb}">
                        <Border Background="Transparent" Padding="{TemplateBinding Padding}">
                            <Rectangle HorizontalAlignment="Center" Width="1" Fill="{TemplateBinding Background}"/>
                        </Border>
                    </ControlTemplate>
                </Setter.Value>
            </Setter>
        </Style>
        <LinearGradientBrush x:Key="GridViewColumnHeaderHoverBackground" EndPoint="0,1" StartPoint="0,0">
            <GradientStop Color="#FFBDEDFF" Offset="0"/>
            <GradientStop Color="#FFB7E7FB" Offset="1"/>
        </LinearGradientBrush>
        <LinearGradientBrush x:Key="GridViewColumnHeaderPressBackground" EndPoint="0,1" StartPoint="0,0">
            <GradientStop Color="#FF8DD6F7" Offset="0"/>
            <GradientStop Color="#FF8AD1F5" Offset="1"/>
        </LinearGradientBrush>
        <Style x:Key="GridViewColumnHeaderStyle1" TargetType="{x:Type GridViewColumnHeader}">
            <Setter Property="HorizontalContentAlignment" Value="Center"/>
            <Setter Property="VerticalContentAlignment" Value="Center"/>
            <Setter Property="Background">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="#FFEEF6FF" Offset="0"/>
                        <GradientStop Color="#FFC4E2FF" Offset="0.393"/>
                        <GradientStop Color="#FFDAECFF" Offset="1"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="BorderBrush">
                <Setter.Value>
                    <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                        <GradientStop Color="#FFD2E1F1" Offset="0"/>
                        <GradientStop Color="#FFA7BACC" Offset="1"/>
                    </LinearGradientBrush>
                </Setter.Value>
            </Setter>
            <Setter Property="BorderThickness" Value="0"/>
            <Setter Property="Padding" Value="2,0,2,0"/>
            <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
            <Setter Value="{DynamicResource GridViewColumnHeaderControlTemplate1}" Property="Template"/>
            <Style.Triggers>
                <Trigger Property="Role" Value="Floating">
                    <Setter Property="Opacity" Value="0.4082"/>
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                                <Canvas x:Name="PART_FloatingHeaderCanvas">
                                    <Rectangle Opacity="0.4697" Width="{TemplateBinding ActualWidth}" Height="{TemplateBinding ActualHeight}" Fill="#FF000000"/>
                                </Canvas>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Trigger>
                <Trigger Property="Role" Value="Padding">
                    <Setter Property="Template">
                        <Setter.Value>
                            <ControlTemplate TargetType="{x:Type GridViewColumnHeader}">
                                <Border x:Name="HeaderBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0,1,0,1"/>
                                <ControlTemplate.Triggers>
                                    <Trigger Property="Height" Value="Auto">
                                        <Setter Property="MinHeight" Value="20"/>
                                    </Trigger>
                                </ControlTemplate.Triggers>
                            </ControlTemplate>
                        </Setter.Value>
                    </Setter>
                </Trigger>
            </Style.Triggers>
        </Style>
        <ControlTemplate x:Key="GridViewColumnHeaderControlTemplate1" TargetType="{x:Type GridViewColumnHeader}">
            <Grid SnapsToDevicePixels="true">
                <Border x:Name="HeaderBorder" Background="{TemplateBinding Background}" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="0,1,0,1" Padding="2,2,2,2">
                    <Grid>
                        <Grid.RowDefinitions>
                            <RowDefinition MaxHeight="7"/>
                            <RowDefinition/>
                        </Grid.RowDefinitions>
                        <Border Grid.RowSpan="2" HorizontalAlignment="Stretch" Padding="{TemplateBinding Padding}" >
                            <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}" HorizontalAlignment="Stretch" Margin="0,0,0,1" x:Name="HeaderContent" VerticalAlignment="{TemplateBinding VerticalContentAlignment}" RecognizesAccessKey="True"/>
                        </Border>
                    </Grid>
                </Border>
                <Canvas>
                    <Thumb x:Name="PART_HeaderGripper" Style="{StaticResource GridViewColumnHeaderGripper}"/>
                </Canvas>
            </Grid>
            <ControlTemplate.Triggers>
                <Trigger Property="IsMouseOver" Value="true">
                    <Setter Property="Background" TargetName="PART_HeaderGripper" Value="Transparent"/>
                    <Setter Property="Background" TargetName="HeaderBorder">
                        <Setter.Value>
                            <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                <GradientStop Color="#FFCDE7FF" Offset="0"/>
                                <GradientStop Color="#FFB2D8FF" Offset="1"/>
                                <GradientStop Color="#FF7FC0FF" Offset="0.357"/>
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                </Trigger>
                <Trigger Property="IsPressed" Value="true">
                    <Setter Property="Visibility" TargetName="PART_HeaderGripper" Value="Hidden"/>
                    <Setter Property="Margin" TargetName="HeaderContent" Value="1,1,0,0"/>
                    <Setter Property="Background" TargetName="HeaderBorder">
                        <Setter.Value>
                            <LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
                                <GradientStop Color="#FFA8D0F5" Offset="0"/>
                                <GradientStop Color="#FF95CAFF" Offset="1"/>
                                <GradientStop Color="#FF5FA2E4" Offset="0.357"/>
                            </LinearGradientBrush>
                        </Setter.Value>
                    </Setter>
                </Trigger>
                <Trigger Property="Height" Value="Auto">
                    <Setter Property="MinHeight" Value="20"/>
                </Trigger>
                <Trigger Property="IsEnabled" Value="false">
                    <Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.GrayTextBrushKey}}"/>
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </UserControl.Resources>
    
    <Grid>
        <ListView x:Name="propertiesList" Style="{StaticResource ListViewStyle1}" ItemsSource="{Binding Path=Parameters}">
            <ListView.ItemContainerStyle>
                <Style TargetType="ListViewItem">
                    <Setter Property="HorizontalContentAlignment"
                Value="Stretch" />
                </Style>
            </ListView.ItemContainerStyle>
            <ListView.View>
                <GridView AllowsColumnReorder="False">
                    <GridViewColumn Width="100" x:Name="col1" Header="Input Parameters" CellTemplate="{StaticResource NameTemplate}"></GridViewColumn>
                    <GridViewColumn Header="Value" Width="{Binding ElementName=helperField, Path=ActualWidth}" CellTemplateSelector="{StaticResource PropertyValueTemplateSelector}"></GridViewColumn>
                </GridView>
            </ListView.View>
        </ListView>
        <!--This is the hidden helper Grid which does the resizing -->
        <Grid Visibility="Hidden">
            <Grid.ColumnDefinitions>
                <!--Width is bound to width of the first GridViewColumn -->
                <ColumnDefinition Width="{Binding ElementName=col1, Path=ActualWidth}"/>
                <!--Width is set to "Fill"-->
                <ColumnDefinition Width="*"/>
                <!--Correction Width-->
                <ColumnDefinition Width="10"/>
            </Grid.ColumnDefinitions>
            <!--This is the hidden helper Field which is used to bind to, using the "Fill" column of the helper grid-->
            <Grid Grid.Column="1" x:Name="helperField"/>
        </Grid>
    </Grid>
</UserControl>
